package cn.edu.scau.service.impl;

import cn.edu.scau.dao.ManagerMapper;
import cn.edu.scau.entity.Manager;
import cn.edu.scau.service.ManagerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ManagerServiceImpl implements ManagerService {
    @Autowired
    ManagerMapper managerMapper;
    @Override
    public List<Manager> selectAll() {
        return managerMapper.selectAll();
    }

    @Override
    public Manager login(String userAccount, String userPassword) {
        if(StringUtils.isBlank(userAccount)||StringUtils.isBlank(userPassword)){
            return null;
        }
        return managerMapper.login(userAccount, userPassword);

    }

    @Override
    public Manager selectByUserAccount(String userAccount) {
        return managerMapper.selectByUserAccount(userAccount);
    }

    @Override
    public boolean updateByUserAccountSelective(Manager record) {
        int line = managerMapper.updateByUserAccountSelective(record);
        return line ==1? true:false;
    }

    @Override
    public boolean insert(Manager record) {
        int line = managerMapper.insert(record);
        return line ==1? true:false;
    }

    @Override
    public boolean updateByPrimaryKey(Manager record) {
        int line = managerMapper.updateByPrimaryKey(record);
        return line ==1? true:false;
    }

    @Override
    public Manager selectByPrimaryKey(Integer userid) {
        return managerMapper.selectByPrimaryKey(userid);
    }

    @Override
    public List<Manager> findById(Integer userId) {
        if(userId<1){
            return null;
        }
        return managerMapper.findById(userId);
    }
}
